package com.tx.gateway.route.controller;

import com.tx.gateway.route.service.DynRouteService;
import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;

@RequestMapping("/gateway/route")
@RestController
public class DynRouteController {

    @Resource
    private DynRouteService dynRouteService;

    @PostMapping("/add")
    public String addRoute(@RequestBody RouteDefinition routeDefinition) {
        return dynRouteService.addRoute(routeDefinition);
    }

    @PostMapping("/update")
    public String updateRoute(@RequestBody RouteDefinition routeDefinition) {
        return dynRouteService.updateRoute(routeDefinition);
    }

    @PostMapping("/delete/{routeId}")
    public Mono<String> deleteRoute(@PathVariable String routeId) {
        return dynRouteService.deleteRoute(routeId);
    }


}
